package dom;

//import java.util.ArrayList;
//import java.util.List;
import java.util.Date;
import java.util.HashMap;

import kb.KnowledgeBase;

public class HyperAlert {
	
	private Date timestamp;
	private HyperAlertType type;
	private HashMap<String,Number> facts;
	
	public HyperAlert() {

	}
	
	public HyperAlert(HyperAlertType type, Date timestamp, long src_ip, int src_port, long dest_ip, int dest_port) {
		this.type = type;
		this.timestamp = timestamp;
		facts = new HashMap<String,Number>();
		facts.put("sourceIP", new Long(src_ip));
		facts.put("sourcePort", new Integer(src_port));
		facts.put("destIP", new Long(dest_ip));
		facts.put("destPort", new Integer(dest_port));
	}
	public HyperAlert(int sigId, Date timestamp, long src_ip, int src_port, long dest_ip, int dest_port) {
		KnowledgeBase kb = KnowledgeBase.getInstance();
		this.type = kb.getHyperAlertType(sigId);
		facts = new HashMap<String,Number>();
		facts.put("sourceIP", new Long(src_ip));
		facts.put("sourcePort", new Integer(src_port));
		facts.put("destIP", new Long(dest_ip));
		facts.put("destPort", new Integer(dest_port));
		this.timestamp = timestamp;
	}

	public HyperAlertType getType() {
		return type;
	}

	public void setType(HyperAlertType type) {
		this.type = type;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	public String getFact(String key){
		Number n = facts.get(key);
		if(n.getClass() == Integer.class){
			key.replace("Port", "IP");
			return facts.get(key).toString()+":"+n.toString();
		}
		if(n.getClass() == Long.class){
			return n.toString();
		}
		return null;
	}

	}
